AppUtils: handle generic collection types for toJsonLiteral#2898
AppUtils: handle generic collection types for toJsonLiteral#2898Luna712 wants to merge 3 commits into
Conversation
| } | ||
| } | ||
| // Handle generic collection/map types where type params are erased at runtime | ||
| // and no serializer can be found via reflection alone |
There was a problem hiding this comment.
Please write test cases for this type of behavior, it looks very easy to break things here.
There was a problem hiding this comment.
Not 100% sure what to write for tests here. I have another method for this to recursively convert things to a JsonElement, more reliable maybe but a least a tiny bit less performant. The issue is that for things like setKey, the type ends up getting erased, which means we have a few other options also, make setKey always use reified for serialized classes, or pass the type directly. I am not 100% sure on the best path here.
There was a problem hiding this comment.
Well, what objects would be improperly serialized in the toJson() function without these helpers? Those are some very good test cases. With those in mind it's much easier to make a good judgement on how to handle this.
There was a problem hiding this comment.
Will look more into this later and provide more information on why once I test again so I can remember what one actually prompted this PR as I can't remember which one now...
This is primarily for set key which calls toJsonLiteral, to avoid having to manually change every set key to determine proper serializers manually. This might have some edge cases where it doesn't fully work but under most circumstances it should.